/*
 * This file is part of WebCL – JavaScript bindings for OpenCL
 * http://webcl.nokiaresearch.com/
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Contact: Jari Nikara  ;jari.nikara@nokia.com;
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 *
 * The package is based on a published Khronos OpenCL 1.1 Specification,
 * see http://www.khronos.org/opencl/.
 *
 * OpenCL is a trademark of Apple Inc.
 */

/** \interface IWebCLKernel
 * IWebCLKernel interface abstracts a WebCL kernel.
 * \see cl_kernel
 */

#include "nsISupports.idl"
#include "nsISecurityCheckedComponent.idl"
#include "nsIVariant.idl"

#include "WebCL_types.idl"

interface IWebCLDevice;

[scriptable, uuid(5d1be1d7-aad2-4eb3-918b-e9551079d634)]
interface IWebCLKernel : nsISecurityCheckedComponent
{
  /** Get kernel info.
   * \param aName Name of the info parameter.
   * \return The resulting value.
   * \see clGetKernelInfo
   * \see WebCL_types
   */
  [implicit_jscontext]
  nsIVariant getKernelInfo (in long aName);

  /** Get kernel work group info.
   * \param aDevice A WebCLDevice instance.
   * \param aName Name of the info parameter.
   * \return The resulting value.
   * \see clGetKernelWorkGroupInfo
   * \see WebCL_types
   */
  [implicit_jscontext]
  nsIVariant getKernelWorkGroupInfo (in nsISupports aDevice, in long aName);

  /** Set the argument value for a specific argument of a kernel.
   * \param aIndex The argument index.
   * \param aValue Value to be set.
   * \param aType Type of the value to be set (one of WebCL.types)
   * \see clSetKernelArg
   * \see WebCL_types
   */
  // TODO: Might be a good idea to support null, e.g. for cl_mems. (impl. as optional)
  [implicit_jscontext]
  void setKernelArg (in long aIndex,
                     in nsIVariant aValue,
                     [optional] in long aType);

  /** Set local kernel argument.
   * \param aIndex The argument index.
   * \param aSize Size of the local argument.
   * \see clSetKernelArg
   * \see WebCL_types
   */
  [implicit_jscontext]
  void setKernelArgLocal (in long aIndex,
                          in unsigned long aSize);

  /** Immediately releases all OpenCL-related resources if any are allocated
   * for this object. The object should not be used anymore after calling
   * this function.
   */
  void releaseCLResources ();
};
